import mysql from 'mysql'
import { mysqlConfig } from '../types/config'

const config: mysqlConfig = {
	host: '119.91.126.241',
	user: 'young',
	password: '000116',
	database: 'young',
}

class MySQL {
  constructor(config: mysqlConfig) {
    this.config = config
  }
  
  private config: mysqlConfig = {
    host: '',
    user: '',
    password: '',
    database: ''
  }

  public executeQuery() {
    return new Promise((resolve, reject) => {
      const connection = mysql.createConnection(this.config)
      connection.connect()
      connection.query('SELECT * FROM figure', function (err: Error, rows: any, fields: any) {
        if (err) reject(err)
        resolve(rows)
      })
      connection.end()
    })
  }
}

export default new MySQL(config)